import React, {useEffect, useState} from 'react';
import {
  View,
  Text,
  TouchableOpacity,
  ActivityIndicator,
  FlatList,
  Image,
  ScrollView,
} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import AreaView from '../../components/Layout/AreaView';
import Tabs from '../../components/Tabs';
import styles from './style';
import Banner from '../../components/Banner';
import BaseUrl from '../../config/BaseUrl';
import {inquiryTypeList} from '../../service/user';

const Community = () => {
  const navigation = useNavigation();
  const [typeList, setTypeList] = useState([]);

  useEffect(() => {
    inquiryTypeList({type: 0, pageNum:1, pageSize:10}).then((res) => {
      console.log(res);
      setTypeList(res.data);
    });
  }, [navigation]);
  return (
    <AreaView>
      <View style={styles.wrapper_container}>
        <Banner />
      </View>
      {/* <Tabs /> */}
      <ScrollView style={styles.community_list}>
        {(typeList || []).map((item, index) => (
          <TouchableOpacity
            onPress={() => {
              navigation.push('TopicList', {
                type: item?.nodeId,
              });
            }}
            activeOpacity={1}
            key={index}
            style={styles.list}>
            <View style={styles.list_head}>
              <Image
                style={styles.avatar}
                // source={require('../../assets/images/avatar.png')}
                source = {{uri: BaseUrl.imgurl + item?.imgs}}
              />
              <View style={styles.info}>
                <Text style={styles.info_name}>{item.nodeName}</Text>
                {/* <Text style={styles.info_time}>5分钟前</Text> */}
              </View>
            </View>
            <View style={styles.topic}>
              <Text style={styles.topic_text}>#{item.nodeName}# {item.nodeDesc}</Text>
            </View>
            <View style={styles.list_bottom}>
              {/* <TouchableOpacity  activeOpacity={1} style={styles.btn} activeOpacity={1}>
                <Image
                  style={styles.btn_icon}
                  source={require('../../assets/images/no_like.png')}
                />
                <Text style={styles.btn_text}>321</Text>
              </TouchableOpacity> */}
              <TouchableOpacity  activeOpacity={1} style={styles.btn} activeOpacity={1}>
                <Image
                  style={styles.btn_icon_coment}
                  source={require('../../assets/images/coment.png')}
                />
                <Text style={styles.btn_text}>{item.mainNum}</Text>
              </TouchableOpacity>
              <TouchableOpacity  activeOpacity={1} style={styles.btn_share} activeOpacity={1}>
                <Image
                  style={styles.btn_icon_share}
                  source={require('../../assets/images/share.png')}
                />
                <Text style={styles.btn_text}>{item.aswNum}</Text>
              </TouchableOpacity>
            </View>
          </TouchableOpacity>
        ))}
      </ScrollView>
    </AreaView>
  );
};

export default Community;
